<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="../js/vue.js"></script>
    <style>
        .bottom-bar{
            list-style-type:none;
            position:absolute;
            bottom:0px;
            left:0px;
            display:flex;
            justify-content:space-around;
            width:100%;
            border-top:1px solid black;
            padding:0px;
        }
    </style>
</head>
<body>
    <div id="app">
        <p>根组件</p>
        <!-- <input type="button" value="切换A|B组件" @click="flag=!flag"> -->
        <input type="button" value="显示A组件" @click="switchCom='compa'">
        <input type="button" value="显示B组件" @click="switchCom='compb'">
        <input type="button" value="显示C组件" @click="switchCom='compc'">
        <hr>
        <comp-a v-if="switchCom=='compa'"></comp-a>
        <comp-b v-if="switchCom=='compb'"></comp-b>
        <comp-c v-if="switchCom=='compc'"></comp-c>
        <hr>
        <component :is="showComp"></component>
        <hr>
        <ul class="bottom-bar">
            <li @click="showComp='compA'">compA</li>
            <li @click="showComp='compB'">compB</li>
            <li @click="showComp='compC'">compC</li>
        </ul>
    </div>
    <template id="compa">
        <div>
           <p>子组件A</p> 
        </div>
    </template>
    <template id="compb">
        <div>
           <p>子组件B</p> 
        </div>
    </template>
    <template id="compc">
        <div>
           <p>子组件C</p> 
        </div>
    </template>
</body>
<script>
    new Vue({
        el:"#app",
        components:{
            compA:{
                template:"#compa"
            },
            compB:{
                template:"#compb"
            },
            compC:{
                template:"#compc"
            }
        },
        data:{
            flag:true,
            switchCom:"compa",
            showComp:""
        }
    })
</script>
</html>